﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using App1AppHandler;

namespace Reborn_Server.App1AppHandler
{
    public class Spell_Alacrity : Buff
    {
        private int PercentAdded = 10;

        public Spell_Alacrity()
        {
            minutesLeft = 3;
        }

        override public void Resume(CreatureBase targetCreatureBase, SpellIcon _spellIcon, int timeRemaining, int castLevel, int castCharacterID, int castInt, int castWis, int optionalValue, string xmlData)
        {
            minutesLeft = timeRemaining;
            base.Resume(targetCreatureBase, _spellIcon, timeRemaining, castLevel, castCharacterID, castInt, castWis, optionalValue, xmlData);

            PercentAdded = PercentAdded + (castLevel / 2);

            if (spellIcon.Skill == "Might")
                TargetCreatureBase.MeleeSpeedPercentModifier = TargetCreatureBase.MeleeSpeedPercentModifier - PercentAdded;
            else if (spellIcon.Skill == "Shadow")
                TargetCreatureBase.RangeSpeedPercentModifier = TargetCreatureBase.RangeSpeedPercentModifier - PercentAdded;

            spellTimer.Start();
        }

        public void Cast(CreatureBase myCreatureBase, int CastLevel, long CreatureGUID)
        {
            List<MapItem> MapItemsWithin12;
            if (base.InitializeCast(myCreatureBase, CastLevel, CreatureGUID, true, out MapItemsWithin12) == false)
                return;

            PercentAdded = PercentAdded + (CastLevel / 2);


            minutesLeft = System.Convert.ToInt32(Math.Floor(myCreatureBase.WisdomTotal / 5.00));

            if (spellIcon.Skill == "Might")
                TargetCreatureBase.MeleeSpeedPercentModifier = TargetCreatureBase.MeleeSpeedPercentModifier - PercentAdded;
            else if (spellIcon.Skill == "Shadow")
                TargetCreatureBase.RangeSpeedPercentModifier = TargetCreatureBase.RangeSpeedPercentModifier - PercentAdded;

            TargetCreatureBase.buffManager.UpdateBuffs();

            //Start Spell Timer
            spellTimer.Start();
        }
        public override void RemoveSpell(bool updateBuffs, bool sendMessage)
        {
            base.RemoveSpell(updateBuffs, sendMessage);
            if (spellIcon.Skill == "Might")
                TargetCreatureBase.MeleeSpeedPercentModifier = TargetCreatureBase.MeleeSpeedPercentModifier + PercentAdded;
            else if (spellIcon.Skill == "Shadow")
                TargetCreatureBase.RangeSpeedPercentModifier = TargetCreatureBase.RangeSpeedPercentModifier + PercentAdded;
        }
    }
}
